package com.taobao.api.request;

import java.util.Map;

import com.taobao.api.ApiRuleException;
import com.taobao.api.TaobaoRequest;
import com.taobao.api.internal.util.RequestCheckUtils;
import com.taobao.api.internal.util.TaobaoHashMap;
import com.taobao.api.response.HanoiTemplateAddResponse;

/**
 * TOP API: taobao.hanoi.template.add request
 * 
 * @author auto create
 * @since 1.0, 2013-08-03 16:51:00
 */
public class HanoiTemplateAddRequest implements TaobaoRequest<HanoiTemplateAddResponse> {

  private Map<String, String> headerMap = new TaobaoHashMap();
  private TaobaoHashMap       udfParams;                      // add
                                                              // user-defined
                                                              // text parameters
  private Long                timestamp;

  /**
   * 认证信息
   */
  private String              appName;

  /**
   * 所使用的数据模板
   */
  private Long                dataTemplateId;

  /**
   * 模板的描述
   */
  private String              description;

  /**
   * 模板的表达式
   */
  private String              expression;

  /**
   * 模板的名称
   */
  private String              name;

  /**
   * 模板的开放策略，默认false不开放
   */
  private Boolean             open;

  /**
   * 设置表达式中参数的类型。ParaVO对象的json格式
   */
  private String              paraList;

  /**
   * 模板的源模板id，用于模板分配，不填或者为0时，则视为创建新模板
   */
  private Long                sourceTemplateId;

  /**
   * 模板的编码
   */
  private String              templateCode;

  public void setAppName(String appName) {
    this.appName = appName;
  }

  public String getAppName() {
    return this.appName;
  }

  public void setDataTemplateId(Long dataTemplateId) {
    this.dataTemplateId = dataTemplateId;
  }

  public Long getDataTemplateId() {
    return this.dataTemplateId;
  }

  public void setDescription(String description) {
    this.description = description;
  }

  public String getDescription() {
    return this.description;
  }

  public void setExpression(String expression) {
    this.expression = expression;
  }

  public String getExpression() {
    return this.expression;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return this.name;
  }

  public void setOpen(Boolean open) {
    this.open = open;
  }

  public Boolean getOpen() {
    return this.open;
  }

  public void setParaList(String paraList) {
    this.paraList = paraList;
  }

  public String getParaList() {
    return this.paraList;
  }

  public void setSourceTemplateId(Long sourceTemplateId) {
    this.sourceTemplateId = sourceTemplateId;
  }

  public Long getSourceTemplateId() {
    return this.sourceTemplateId;
  }

  public void setTemplateCode(String templateCode) {
    this.templateCode = templateCode;
  }

  public String getTemplateCode() {
    return this.templateCode;
  }

  public Long getTimestamp() {
    return this.timestamp;
  }

  public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
  }

  public String getApiMethodName() {
    return "taobao.hanoi.template.add";
  }

  public Map<String, String> getTextParams() {
    TaobaoHashMap txtParams = new TaobaoHashMap();
    txtParams.put("app_name", this.appName);
    txtParams.put("data_template_id", this.dataTemplateId);
    txtParams.put("description", this.description);
    txtParams.put("expression", this.expression);
    txtParams.put("name", this.name);
    txtParams.put("open", this.open);
    txtParams.put("para_list", this.paraList);
    txtParams.put("source_template_id", this.sourceTemplateId);
    txtParams.put("template_code", this.templateCode);
    if (this.udfParams != null) {
      txtParams.putAll(this.udfParams);
    }
    return txtParams;
  }

  public void putOtherTextParam(String key, String value) {
    if (this.udfParams == null) {
      this.udfParams = new TaobaoHashMap();
    }
    this.udfParams.put(key, value);
  }

  public Class<HanoiTemplateAddResponse> getResponseClass() {
    return HanoiTemplateAddResponse.class;
  }

  public void check() throws ApiRuleException {
    RequestCheckUtils.checkNotEmpty(appName, "appName");
    RequestCheckUtils.checkNotEmpty(dataTemplateId, "dataTemplateId");
    RequestCheckUtils.checkNotEmpty(expression, "expression");
    RequestCheckUtils.checkNotEmpty(name, "name");
    RequestCheckUtils.checkNotEmpty(templateCode, "templateCode");
    RequestCheckUtils.checkMaxLength(templateCode, 50, "templateCode");
  }

  public Map<String, String> getHeaderMap() {
    return headerMap;
  }
}
